<?php
namespace app\admin\controller;
use think\Controller;
use think\Session;
use think\Request;
use think\Db;
use app\push\controller\Event;
class Pushdata extends Controller
{
    public function index() {
        var_dump(Session::get('admin_id'));
        if(!Session::get('admin_id')){
            return false;
        }
        $request    = Request::instance();
        $data['type']       = $request->post('type');
        $data['client_id'] = $request->post('myClientId');
        $data['admin_id']  = Session::get('admin_id');
        if(Db::name('swp')->insert($data)){
            return json(['status'=>200]);
        }
    }
    /**
     *
     *将请求写入交换文件swp.txt，用于gatewaywoker，接收并执行
     *
     */
    public static function swp() {
        $request = Request::instance();
        $data['client_id'] = $request->post('myClientId');
        $data['admin_id']  = $_SESSION['admin_id'];
        $data['operation'] = $request->post('type');
    }
}
